import Vue from 'vue'
import store from '../store'
const has = Vue.directive('has', {
    inserted: function (el, binging, vnode) {
        //获取按钮权限
        let btnPermissions = vnode.context.$route.meta.btnPermissions;
        var userUserTypeId = store.state.userUserTypeId
        if (!Vue.prototype.$_has(btnPermissions, userUserTypeId) && el.parentElement) {
            el.parentElement.removeChild(el);
        }
    }
})
//权限检查方法
Vue.prototype.$_has = function (value, userUserTypeId) {
    let uid = Number(userUserTypeId)
    let idExist = false;
    if (uid == undefined || uid == null) {
        return false;
    }
    if (value.indexOf(uid) > -1) {
        idExist = true
    }
    return idExist
}
export default {
    has
};